Technical Field
The present invention relates to software analysis, particularly to reordering the condition checks within software code.
Description of the Related Art
Elseif is a conditional statement in computer code that combines the if and else conditional statements. Elseif will extend an if statement to execute a different statement in case the preceding if expression is evaluated as FALSE. Unlike an else statement, the body block of an elseif statement is executed only if the elseif conditional expression is evaluated as TRUE.
When a computer program contains if and elseif statements, the if statement is checked first. As indicated, when the if statement is evaluated as FALSE, then the elseif statement is checked.
In computer programming languages such as Java™ and other scripting languages, there are many elseif statements that use instanceof operations to test and evaluate objects. The syntax of an instanceof statement is “object instanceof constructor”. The constructer is the function that the object is tested against. Instanceof statements carry a high cost in terms of computer run time, processing resources, etc., particularly when compared to comparing and testing variables of primitive data types, such as integers.
In the execution of the computer program, when the if statement is rarely evaluated as TRUE and the elseif statement is frequently evaluated as TRUE, then the cost in terms of computer run time, processing resources, etc. is increased.